package com.qidian.server.messages.plugin2server;

import java.io.UnsupportedEncodingException;

import com.qidian.server.messages.Message;

/**
 *  取号消息，
 *  用于插件从服务器端获取消息的ID，该ID用于上传图片、声音文件等。
 * 
 * */
public class NumberTakingMessage extends Message implements IPlugin2Server
{

    public static int msg_type = msg_type_0 ;
    
    public String userName ;
    public String maskCode ;
    
    public static NumberTakingMessage toMessage(byte[] message, int offset, int length) throws UnsupportedEncodingException
    {
        String msgString = new String(message,offset,length,charSet) ;
        String[] splits = msgString.split("#") ;
        if (splits.length != 2)
            return null ;
        NumberTakingMessage msg = new NumberTakingMessage() ;
        msg.setUserName(splits[0]) ;
        msg.setMaskCode(splits[1]) ;
        return msg ;
    }

    @Override
    public int toBytes(byte[] content, int offset, int length)
    {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public boolean isValid()
    {
        return false;
    }

    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    public String getMaskCode()
    {
        return maskCode;
    }

    public void setMaskCode(String maskCode)
    {
        this.maskCode = maskCode;
    }

}
